package com.colin.aiyi.dao.ImpxUtils;

import com.colin.aiyi.app.Constant;
import com.colin.aiyi.entity.response.BaseResponse;
import com.colin.aiyi.entity.response.LoginResponse;
import com.colin.aiyi.entity.User;

import org.xutils.http.RequestParams;

/**
 * Created by hl on 2017/5/5.
 */

public class ImpRegister extends com.colin.aiyi.dao.ImpxUtils.AbsServicexUtils{

    @Override
    public void onSuccess(String result) {
        super.onSuccess(result);
        if (callback==null)
        {
            sendMsgToView(BaseResponse.class,result);
        }else {
            LoginResponse loginResponse=gson.fromJson(result,LoginResponse.class);
            callback.onSuccess(loginResponse);
        }
    }

    /*********
     * 注册
     * clientId	是	string	xx
     clientSecret	是	string	xx
     telNo	是	string	手机号
     password	是	string	密码
     messageCode	是	string	验证码
     */

    @Override
    public <V> void getObject(V v) {
        super.getObject(v);
        if (v instanceof User) {
            User user = (User) v;
            RequestParams params = new RequestParams(Constant.register);
            params.addBodyParameter("accessToken", "");
            params.addBodyParameter("clientId", Constant.CLIENT_ID);
            params.addBodyParameter("clientSecret", Constant.CLIENT_SECRET);
            params.addBodyParameter("telNo", user.getTelNo());
            params.addBodyParameter("password", user.getPassword());
            params.addBodyParameter("messageCode", user.getMessageCode());
            sendToServer(params, 1);
        }
    }




}
